#include<iostream>
#include<stdio.h>
#include"database_manager.h"
#include"server.h"

#define SRC_IP "192.168.88.128"
#define SRC_PROT 8888

using namespace std;
int main(int argc, const char *argv[])
{
    try
    {
        // 创建数据库模块
        auto db_manager = make_shared<DatabaseManager>("User.db", "Dict.db");

        if(!db_manager->initTables())
        {
            cerr << "数据库初始化失败" << endl;
            return -1;
        }
        // 创建线程池模块
        auto t_pool = make_shared<ThreadPool>(5);
        // 创建服务器模块
        auto server_manager = make_shared<Server>(db_manager, t_pool, SRC_IP, SRC_PROT);

        server_manager->start();
        server_manager->stop();
    }
    catch(const std::exception& e)
    {
        std::cerr << e.what() << '\n';
    }
    
    return 0;
}